home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / incoming / jstools-.6v3 / jstools- / jstools-tk3.6v3.0 / lib / jdoc_hypertext.tcl < prev    next >
Encoding:
Text File  |  1995-02-05  |  3.1 KB  |  90 lines

  1. # jdoc_hypertext.tcl - hypertext procedures for jdoc
  2. # Copyright 1992-1994 by Jay Sekora.  All rights reserved, except 
  3. # that this file may be freely redistributed in whole or in part 
  4. # for non¡profit, noncommercial use.
  5.  
  6. ##############################################################################
  7. # jdoc:x_link w x y - go to link clicked on (hypertext)
  8. ##############################################################################
  9.  
  10. proc jdoc:x_link { {w} {x} {y} args } {
  11.   set tags [$w tag names @$x,$y]
  12.   
  13.   foreach tag $tags {                ;# find topic-name tag
  14.     if [string match "jdoc:link:*" $tag] {
  15.       set link [string range $tag 10 end]    ;# strip off "jdoc:link:"
  16.       if [string match "#*" $link] {        ;# anchor within this doc
  17.         set anchor [string trimleft $link "#"]
  18.         jdoc:go_to_anchor $anchor $w $x $y
  19.       } else {                    ;# separate doc
  20.         exec jdoc $link &
  21.       }
  22.       break
  23.     }
  24.   }
  25. }
  26.  
  27. ##############################################################################
  28. # jdoc:x_topic w x y - view doc clicked on (hypertext)
  29. ##############################################################################
  30.  
  31. proc jdoc:x_topic { {w} {x} {y} args } {
  32.   puts stderr "Warning: obsolete procedure jdoc:x_topic invoked."
  33.   set tags [$w tag names @$x,$y]
  34.   
  35.   foreach tag $tags {                ;# find topic-name tag
  36.     if [string match "jdoc:topic:*" $tag] {
  37.       set topic [string range $tag 11 end]    ;# strip off "jdoc:topic:"
  38.       exec jdoc $topic &
  39.       break
  40.     }
  41.   }
  42. }
  43.  
  44. ##############################################################################
  45. # jdoc:x_section w x y - go to section name clicked on (hypertext)
  46. ##############################################################################
  47.  
  48. proc jdoc:x_section { {w} {x} {y} args } {
  49.   puts stderr "Warning: obsolete procedure jdoc:x_section invoked."
  50.   set tags [$w tag names @$x,$y]
  51.   
  52.   foreach tag $tags {                ;# find section-name tag
  53.     if [string match "jdoc:section:*" $tag] {
  54.       set section [string range $tag 13 end]    ;# strip off "jdoc:section:"
  55.       .menu.sections.m invoke $section
  56.       break
  57.     }
  58.   }
  59. }
  60.  
  61. ##############################################################################
  62. # jdoc:x_manpage w x y - view man page name clicked on (hypertext)
  63. ##############################################################################
  64.  
  65. proc jdoc:x_manpage { {w} {x} {y} args } {
  66.   set tags [$w tag names @$x,$y]
  67.   
  68.   foreach tag $tags {                ;# find manpage-name tag
  69.     if [string match "jdoc:manpage:*" $tag] {
  70.       set manpage [string range $tag 13 end]    ;# strip off "jdoc:manpage:"
  71.       catch {exec man $manpage |& ul -i} mantext
  72.       j:more -height 30 \
  73.         -title "Manual page for `$manpage'" \
  74.         -text $mantext
  75.       break
  76.     }
  77.   }
  78. }
  79.  
  80. ######################################################################
  81. # jdoc:go_to_anchor anchor w x y - go to a particular anchor
  82. ######################################################################
  83.  
  84. proc jdoc:go_to_anchor { anchor w args } {
  85.   if [catch {$w yview jdoc:anchorname:${anchor}.first}] {
  86.     j:alert -text "Unable to find anchor `${anchor}' in this document."
  87.   }
  88. }
  89.